package Eyjafjalla.card.attack;

import Eyjafjalla.action.EyjafjallaAttackAction;
import Eyjafjalla.action.MakeTempCardInCloudAction;
import Eyjafjalla.card.AbstractEyjafjallaCard;
import Eyjafjalla.modcore.EyjafjallaTag;
import Eyjafjalla.patch.CloudPatch;
import Eyjafjalla.patch.MelodyPatch;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.DamageAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;

public class InstantFireworks_Eyjafjalla extends AbstractEyjafjallaCard {
    public static final String ID = "InstantFireworks_Eyjafjalla";
    private static final CardStrings cardStrings;

    public InstantFireworks_Eyjafjalla(){
        super(ID, cardStrings.NAME,1,cardStrings.DESCRIPTION,CardType.ATTACK,CardRarity.COMMON,CardTarget.ENEMY);
        this.baseDamage = 7;
        this.damage =7;
        this.baseMagicNumber=4;
        this.magicNumber=4;
        setFireDescription(cardStrings.EXTENDED_DESCRIPTION[0]);
    }

    @Override
    public AbstractCard makeCopy() {
        return new InstantFireworks_Eyjafjalla();
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        addToBot(new EyjafjallaAttackAction());
        addToBot(new DamageAction(m,new DamageInfo(p,damage,damageTypeForTurn), AbstractGameAction.AttackEffect.SLASH_VERTICAL));
    }

    @Override
    public boolean ignoreMelodyType() {
        return CloudPatch.CloudField.isFire.get(this);
    }

    @Override
    public void triggerOnGlowCheck() {
        this.glowColor = AbstractCard.BLUE_BORDER_GLOW_COLOR.cpy();
        if(MelodyPatch.currentSingle!=null){
            this.glowColor = AbstractCard.GOLD_BORDER_GLOW_COLOR.cpy();
        }
    }

    @Override
    public void calculateCardDamage(AbstractMonster mo) {
        int trueD = baseDamage;
        if(MelodyPatch.currentSingle!=null){
            baseDamage+=this.magicNumber;
        }
        super.calculateCardDamage(mo);
        baseDamage = trueD;
        isDamageModified = baseDamage!=damage;
    }

    @Override
    public void applyPowers() {
        int trueD = baseDamage;
        if(MelodyPatch.currentSingle!=null){
            baseDamage+=this.magicNumber;
        }
        super.applyPowers();
        baseDamage = trueD;
        isDamageModified = baseDamage!=damage;
    }

    @Override
    public AbstractCard removeCardWhenObtained() {
        AbstractCard card = null;
        for(AbstractCard c: AbstractDungeon.player.masterDeck.group){
            if(c.cardID.equals(Strike_Eyjafjalla.ID)){
                card = c;
                break;
            }
        }
        return card;
    }

    @Override
    public void upgrade() {
        if(!this.upgraded){
            upgradeName();
            upgradeDamage(3);
            upgradeMagicNumber(3);
        }
    }

    static {
        cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    }
}

